package com.csw;

/**
 * @author A
 * @version 1.0
 * @description: 生成地雷
 * @date 2022/11/23 0:36
 */
public class BottomRay {

    //存放坐标
    static int[] rays = new int[GameUtil.RAY_MAX * 2];
    //地雷坐标
    int x, y;
    //是否能放雷
    boolean isPlace =true;
    void newRay(){

        for (int i = 0; i < GameUtil.RAY_MAX * 2; i += 2) {
            x = (int) (Math.random() * GameUtil.Map_W + 1);//1-12
            y = (int) (Math.random() * GameUtil.Map_H + 1);//1-12



            for (int j = 0; j < i; j+=2) {
                if (x==rays[j]&&y==rays[j+1]){
                    //雷重合了,i回退
                    i-=2;
                    isPlace=false;
                    //跳出循环
                    break;
                }
            }
            if (isPlace){
                rays[i] = x;
                rays[i + 1] = y;
            }
            isPlace=true;

        }

        for (int i = 0; i < GameUtil.RAY_MAX * 2; i += 2) {
            GameUtil.DATA_BOTTOM[rays[i]][rays[i + 1]] = -1;
        }
    }



}
